<?php
namespace Admin\Controller;

class CheckInApplyController extends BaseController
{
    public function indexAction()
    {
        $CheckInApply = M('CheckInApply');
        $condition = array();
        $count = $CheckInApply->where($condition)->count();
        $Page = new \Think\Page($count, 50);
        $show = $Page->show();
        $list = $CheckInApply->where($condition)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
        $this->assign('page', $show);
        $this->assign('list', $list);
        $this->display();
    }

    public function viewAction()
    {
        $CheckInApply = D('CheckInApply');
        if (IS_POST) {
            $data = $CheckInApply->create($_POST['CheckInApply']);
            if (false !== $data) {
                if (false !== $CheckInApply->save()) {
                    $this->success('更新成功', U('CheckInApply/index'));
                } else {
                    $this->error('更新失败（失败原因：' . $CheckInApply->getError() . '）');
                }
            } else {
                $this->error($CheckInApply->getError());
            }
        } else {
            $id = I('get.id', 0, 'intval');
            $info = $CheckInApply->find($id);
            $this->assign('info', $info);
            $this->display();
        }
    }
}